<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php echo $this->breadCrumbs(); ?>
  </div>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/order.png" alt="" /> <?php echo $_['heading_title']; ?> #<?php echo $order_id;?></h1>
      <div class="buttons">
	  <?php if (isset($previous)) { ?>
	  <a href="<?echo $previous; ?>" class="button">&lt;&lt;Previous</a>
	  <?php } ?>
	  <?php if (isset($next)) { ?>
	  <a href="<?echo $next; ?>" class="button">Next &gt;&gt;</a>
	  <?php } ?>
	  |
	  <a onclick="window.open('<?php echo UA('sale/order/invoice', 'order_id=' . $order_id); ?>');" class="button"><?php echo $_['button_invoice']; ?></a>
	  <a onclick="window.open('<?php echo UA('sale/order/shippinglabel', 'order_id=' . $order_id); ?>');" class="button"><?php echo $_['text_shipping_label']; ?></a>
	  <a href="<?php echo UA('sale/order'); ?>" class="button"><?php echo $_['button_cancel']; ?></a></div>
    </div>
    <div class="content">
      <div class="vtabs"><a href="#tab-order"><?php echo $_['tab_order']; ?></a><a href="#tab-payment"><?php echo $_['tab_payment']; ?></a>
        <?php if ($shipping_method) { ?>
        <a href="#tab-shipping"><?php echo $_['tab_shipping']; ?></a>
		<a href="#tab-shipping-history"><?php echo $_['tab_shipping_history']; ?></a>
        <?php } ?>
        <a href="#tab-product"><?php echo $_['tab_product']; ?></a>
        <a href="#tab-history"><?php echo $_['tab_order_history']; ?></a>
        <a href="#tab-service"><?php echo $_['tab_order_service']; ?></a>
        <?php if ($maxmind_id) { ?>
        <a href="#tab-fraud"><?php echo $_['tab_fraud']; ?></a>
        <?php } ?>
      </div>
      <div id="tab-order" class="vtabs-content">
        <table class="form">
          <tr>
            <td><?php echo $_['text_order_id']; ?></td>
            <td><b>#<?php echo $order_id; ?></b></td>
          </tr>
          <tr>
            <td><?php echo $_['text_invoice_no']; ?></td>
            <td><?php if ($invoice_no) { ?>
              <?php echo $invoice_no; ?>
              <?php } else { ?>
              <span id="invoice"><b>[</b> <a id="invoice-generate"><?php echo $_['text_generate']; ?></a> <b>]</b></span>
              <?php } ?></td>
          </tr>
          <tr>
            <td><?php echo $_['text_store_name']; ?></td>
            <td><?php echo $store_name; ?></td>
          </tr>
          <tr>
            <td><?php echo $_['text_store_url']; ?></td>
            <td><a onclick="window.open('<?php echo $store_url; ?>');"><?php echo $store_url; ?></a></td>
          </tr>
          <?php if ($customer) { ?>
          <tr>
            <td><?php echo $_['text_customer']; ?></td>
            <td><a href="<?php echo $customer; ?>" target="_blank"><?php echo $firstname; ?> <?php echo $lastname; ?></a></td>
          </tr>
          <?php } else { ?>
          <tr>
            <td><?php echo $_['text_customer']; ?></td>
            <td><?php echo $firstname; ?> <?php echo $lastname; ?></td>
          </tr>
          <?php } ?>
          <?php if ($customer_group) { ?>
          <tr>
            <td><?php echo $_['text_customer_group']; ?></td>
            <td><?php echo $customer_group; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><?php echo $_['text_email']; ?></td>
            <td><?php echo $email; ?></td>
          </tr>
          <tr>
            <td><?php echo $_['text_telephone']; ?></td>
            <td><?php echo $telephone; ?></td>
          </tr>
          <?php if ($fax) { ?>
          <tr>
            <td><?php echo $_['text_fax']; ?></td>
            <td><?php echo $fax; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><?php echo $_['text_total']; ?></td>
            <td><span class="red"><?php echo $total; ?></span>
              <?php if ($credit && $customer) { ?>
              <?php if (!$credit_total) { ?>
              <span id="credit"><b>[</b> <a id="credit-add"><?php echo $_['text_credit_add']; ?></a> <b>]</b></span>
              <?php } else { ?>
              <span id="credit"><b>[</b> <a id="credit-remove"><?php echo $_['text_credit_remove']; ?></a> <b>]</b></span>
              <?php } ?>
              <?php } ?></td>
          </tr>
          <?php if ($reward && $customer) { ?>
          <tr>
            <td><?php echo $_['text_reward']; ?></td>
            <td><?php echo $reward; ?>
              <?php if (!$reward_total) { ?>
              <span id="reward"><b>[</b> <a id="reward-add"><?php echo $_['text_reward_add']; ?></a> <b>]</b></span>
              <?php } else { ?>
              <span id="reward"><b>[</b> <a id="reward-remove"><?php echo $_['text_reward_remove']; ?></a> <b>]</b></span>
              <?php } ?></td>
          </tr>
          <?php } ?>
          <?php if ($order_status) { ?>
          <tr>
            <td><?php echo $_['text_order_status']; ?></td>
            <td id="order-status"><b><?php echo $order_status; ?></b></td>
          </tr>
          <?php } ?>
          <?php if ($comment) { ?>
          <tr>
            <td><?php echo $_['text_comment']; ?></td>
            <td><?php echo $comment; ?></td>
          </tr>
          <?php } ?>
          <?php if ($affiliate) { ?>
          <tr>
            <td><?php echo $_['text_affiliate']; ?></td>
            <td><a href="<?php echo $affiliate; ?>"><?php echo $affiliate_firstname; ?> <?php echo $affiliate_lastname; ?></a></td>
          </tr>
          <tr>
            <td><?php echo $_['text_commission']; ?></td>
            <td><?php echo $commission; ?>
              <?php if (!$commission_total) { ?>
              <span id="commission"><b>[</b> <a id="commission-add"><?php echo $_['text_commission_add']; ?></a> <b>]</b></span>
              <?php } else { ?>
              <span id="commission"><b>[</b> <a id="commission-remove"><?php echo $_['text_commission_remove']; ?></a> <b>]</b></span>
              <?php } ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip) { ?>
          <tr>
            <td><?php echo $_['text_ip']; ?></td>
            <td><?php echo $ip; ?></td>
          </tr>
          <?php } ?>
          <?php if ($forwarded_ip) { ?>
          <tr>
            <td><?php echo $_['text_forwarded_ip']; ?></td>
            <td><?php echo $forwarded_ip; ?></td>
          </tr>
          <?php } ?>
          <?php if ($user_agent) { ?>
          <tr>
            <td><?php echo $_['text_user_agent']; ?></td>
            <td><?php echo $user_agent; ?></td>
          </tr>
          <?php } ?>
          <?php if ($accept_language) { ?>
          <tr>
            <td><?php echo $_['text_accept_language']; ?></td>
            <td><?php echo $accept_language; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><?php echo $_['text_date_added']; ?></td>
            <td><?php echo $date_added; ?></td>
          </tr>
          <tr>
            <td><?php echo $_['text_date_modified']; ?></td>
            <td><?php echo $date_modified; ?></td>
          </tr>
			<tr>
				<td><?php echo $_['text_note']; ?></td>
				<td><?php echo $note; ?></td>
			</tr>
        </table>
      </div>
      <div id="tab-payment" class="vtabs-content">
        <table class="form">
          <tr>
            <td><?php echo $_['text_firstname']; ?></td>
            <td><?php echo $payment_firstname; ?></td>
          </tr>
          <tr>
            <td><?php echo $_['text_lastname']; ?></td>
            <td><?php echo $payment_lastname; ?></td>
          </tr>
          <?php if ($payment_company) { ?>
          <tr>
            <td><?php echo $_['text_company']; ?></td>
            <td><?php echo $payment_company; ?></td>
          </tr>
          <?php } ?>
          <?php if ($payment_company_id) { ?>
          <tr>
            <td><?php echo $_['text_company_id']; ?></td>
            <td><?php echo $payment_company_id; ?></td>
          </tr>
          <?php } ?>          
          <?php if ($payment_tax_id) { ?>
          <tr>
            <td><?php echo $_['text_tax_id']; ?></td>
            <td><?php echo $payment_tax_id; ?></td>
          </tr>
          <?php } ?>            
          <tr>
            <td><?php echo $_['text_address_1']; ?></td>
            <td><?php echo $payment_address_1; ?></td>
          </tr>
          <?php if ($payment_address_2) { ?>
          <tr>
            <td><?php echo $_['text_address_2']; ?></td>
            <td><?php echo $payment_address_2; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><?php echo $_['text_city']; ?></td>
            <td><?php echo $payment_city; ?></td>
          </tr>
          <?php if ($payment_postcode) { ?>
          <tr>
            <td><?php echo $_['text_postcode']; ?></td>
            <td><?php echo $payment_postcode; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><?php echo $_['text_zone']; ?></td>
            <td><?php echo $payment_zone; ?></td>
          </tr>
          <?php if ($payment_zone_code) { ?>
          <tr>
            <td><?php echo $_['text_zone_code']; ?></td>
            <td><?php echo $payment_zone_code; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><?php echo $_['text_country']; ?></td>
            <td><?php echo $payment_country; ?></td>
          </tr>
          <tr>
            <td><?php echo $_['text_payment_method']; ?></td>
            <td><p><b><?php echo $payment_method; ?></b></p>
				<table border='0' bgcolor='#88A8AC' cellspacing='1' cellpadding="3" width="70%">
					<tr bgcolor='#ffffff'>
						<td width="120"><?php echo $_['text_payment_payer_status'];?></td>
						<td><?php echo $payment_payer_status;?></td>
					</tr>
					<tr bgcolor='#ffffff'>
						<td><?php echo $_['text_payment_transaction_id'];?></td>
						<td><?php echo $payment_transaction_id; ?></td>
					</tr>
					<tr bgcolor='#ffffff'>
						<td><?php echo $_['text_payment_type']; ?></td>
						<td><?php echo $payment_type; ?></td>
					</tr>
					<tr bgcolor='#ffffff'>
						<td><?php echo $_['text_payment_fee_amt']; ?></td>
						<td><?php echo $payment_fee_amt; ?></td>
					</tr>
					<tr bgcolor='#ffffff'>
						<td><?php echo $_['text_payment_status']; ?></td>
						<td><?php echo $payment_status; ?></td>
					</tr>
				</table>
			</td>
          </tr>
		  
        </table>
      </div>
      <?php if ($shipping_method) { ?>
      <div id="tab-shipping" class="vtabs-content">
        <table class="form">
          <tr>
            <td><?php echo $_['text_firstname']; ?></td>
            <td><?php echo $shipping_firstname; ?></td>
          </tr>
          <tr>
            <td><?php echo $_['text_lastname']; ?></td>
            <td><?php echo $shipping_lastname; ?></td>
          </tr>
          <?php if ($shipping_company) { ?>
          <tr>
            <td><?php echo $_['text_company']; ?></td>
            <td><?php echo $shipping_company; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><?php echo $_['text_address_1']; ?></td>
            <td><?php echo $shipping_address_1; ?></td>
          </tr>
          <?php if ($shipping_address_2) { ?>
          <tr>
            <td><?php echo $_['text_address_2']; ?></td>
            <td><?php echo $shipping_address_2; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><?php echo $_['text_city']; ?></td>
            <td><?php echo $shipping_city; ?></td>
          </tr>
          <?php if ($shipping_postcode) { ?>
          <tr>
            <td><?php echo $_['text_postcode']; ?></td>
            <td><?php echo $shipping_postcode; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><?php echo $_['text_zone']; ?></td>
            <td><?php echo $shipping_zone; ?></td>
          </tr>
          <?php if ($shipping_zone_code) { ?>
          <tr>
            <td><?php echo $_['text_zone_code']; ?></td>
            <td><?php echo $shipping_zone_code; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><?php echo $_['text_country']; ?></td>
            <td><?php echo $shipping_country; ?></td>
          </tr>
          <?php if ($shipping_method) { ?>
          <tr>
            <td><?php echo $_['text_shipping_method']; ?></td>
            <td><b><?php echo $shipping_method; ?></b></td>
          </tr>
          <tr>
          	<td><?php echo $_['text_shipping_carrier']?>:</td>
          	<td>
          		<select name="shipping_carrier_code" id="shipping_carrier_code">
					<option value=""></option>
					<?php echo form_select_option($carriers, $shipping_carrier_code, null, 'code', 'name');?>
				</select><span id="shipping_carrier_msg"></span>
          	</td>
          </tr>
          <?php } ?>
        </table>
      </div>
	   <div id="tab-shipping-history" class="vtabs-content">
		<div id="shipping-history"></div>
		<div id="shipping-history-form" style="border-top:1px solid #bababa">
	    <table class="form">
		   <tr>
			   <td><?php echo $_['text_shipping_date']; ?></td>
			   <td><input type="text" class="date" name="ship_date" value="<?php echo date('Y-m-d'); ?>"></td>
		   </tr>
		   <tr>
			   <td><?php echo $_['text_shipping_carrier']; ?></td>
			   <td>
				<select name="ship_carrier">
					<option></option>
					<?php echo form_select_option($carriers, $shipping_carrier_code, null, 'code', 'name');?>
				</select>
			   </td>
		   </tr>
		   <tr>
			   <td><?php echo $_['text_track_number']; ?></td>
			   <td><input type="text" name="track_number"></td>
		   </tr>
		   <tr>
				<td><?php echo $_['text_shipping_package']; ?></td>
				<td>
					<table cellpadding="3">
            <tr>
            <td>
					 <?php foreach ($products as $product) { ?>					 
              <div class="fl pd10"><img src="<?php echo $product['image']; ?>" alt="" width="100" /> [ <?php echo $product['model']?>]<br/>
              <small>Qty:</small> <input type="text" name="products[<?php echo $product['product_id']; ?>]" size="5" value="<?php echo $product['quantity'];?>"> / <span class="red"><?php echo $product['quantity']; ?></span> </div>
					 <?php } ?>
            </td>
           </tr>
					</table>
				</td>
		   </tr>
		   <tr>
			   <td><?php echo $_['text_shipping_remark']; ?></td>
			   <td><textarea name="remark" cols="40" rows="3" style="width: 99%"></textarea>
			   <div style="margin-top: 10px; text-align: right;"><a id="button-shipping-history" class="button"><?php echo $_['button_add_history']; ?></a></div></td>
		   </tr>
	   </table>
	   </div>
	   </div>
      <?php } ?>
      <div id="tab-product" class="vtabs-content">
        <table class="list">
          <thead>
            <tr>
			  <td class="left" width="110"><?php echo $_['column_image']; ?></td>
              <td class="left" width="300"><?php echo $_['column_product']; ?></td>
              <td class="left"><?php echo $_['column_model']; ?></td>
              <td class="right"><?php echo $_['column_quantity']; ?></td>
			        <td class="right">Shipped</td>
              <td class="right"><?php echo $_['column_price']; ?></td>
              <td class="right"><?php echo $_['column_total']; ?></td>
            </tr>
          </thead>
          <tbody>
            <?php foreach ($products as $product) { ?>
            <tr>
			  <td class="left"><img src="<?php echo $product['image']; ?>" alt="" width="100" /></td>
              <td class="left"><a href="<?php echo $product['href']; ?>" target="_blank"><?php echo $product['name']; ?></a>
                <?php foreach ($product['option'] as $option) { ?>
                <br />
                <?php if ($option['type'] != 'file') { ?>
                &nbsp;<small> - <?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
                <?php } else { ?>
                &nbsp;<small> - <?php echo $option['name']; ?>: <a href="<?php echo $option['href']; ?>"><?php echo $option['value']; ?></a></small>
                <?php } ?>
                <?php } ?></td>
              <td class="left"><?php echo $product['model']; ?></td>
              <td class="right"><?php echo $product['quantity']; ?></td>
			   <td class="right"><?php echo $product['shipped_qty']; ?></td>
              <td class="right">
                <?php if ($product['org_price'] != $product['price']) { ?>
                  <span class="txt_lt"><?php echo $product['org_price']; ?></span><br/>
                  <span class="red"><?php echo $product['price']; ?></span>
                <?php } else { ?>
                <?php echo $product['price']; ?>
                <?php } ?>
                <?php if ($product['promotion']) { ?><em class="badge"><?php echo $product['promotion']; ?></em><?php } ?>
              </td>
              <td class="right"><?php echo $product['total']; ?></td>
            </tr>
            <?php } ?>
            <?php foreach ($vouchers as $voucher) { ?>
            <tr>
              <td></td>
              <td class="left"><a href="<?php echo $voucher['href']; ?>"><?php echo $voucher['description']; ?></a></td>
              <td class="left"></td>
              <td class="right">1</td>
              <td></td>
              <td class="right"><?php echo $voucher['amount']; ?></td>
              <td class="right"><?php echo $voucher['amount']; ?></td>
            </tr>
            <?php } ?>
          </tbody>
          <?php foreach ($totals as $totals) { ?>
          <tbody id="totals">
            <tr>
              <td colspan="6" class="right"><?php echo $totals['title']; ?>:</td>
              <td class="right"><?php echo $totals['text']; ?></td>
            </tr>
          </tbody>
          <?php } ?>
        </table>
        <?php if ($downloads) { ?>
        <h3><?php echo $_['text_download']; ?></h3>
        <table class="list">
          <thead>
            <tr>
              <td class="left"><b><?php echo $_['column_download']; ?></b></td>
              <td class="left"><b><?php echo $_['column_filename']; ?></b></td>
              <td class="right"><b><?php echo $_['column_remaining']; ?></b></td>
            </tr>
          </thead>
          <tbody>
            <?php foreach ($downloads as $download) { ?>
            <tr>
              <td class="left"><?php echo $download['name']; ?></td>
              <td class="left"><?php echo $download['filename']; ?></td>
              <td class="right"><?php echo $download['remaining']; ?></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
        <?php } ?>
      </div>
      <div id="tab-history" class="vtabs-content">
        <div id="history"></div>
        <table class="form">
          <tr>
            <td><?php echo $_['entry_order_status']; ?></td>
            <td><select name="order_status_id">
			<?php echo form_select_option($order_statuses, $order_status_id, true);?>
              </select></td>
          </tr>
          <tr>
            <td><?php echo $_['entry_notify']; ?></td>
            <td><input type="checkbox" name="notify" value="1" /></td>
          </tr>
          <tr>
            <td><?php echo $_['entry_comment']; ?></td>
            <td><textarea name="comment" cols="40" rows="8" style="width: 99%"></textarea>
              <div style="margin-top: 10px; text-align: right;"><a id="button-history" class="button"><?php echo $_['button_add_history']; ?></a></div></td>
          </tr>
        </table>
      </div>
      <div id="tab-service" class="vtabs-content">
        <div id="service"></div>
        <input type="hidden" name="customer_id" value="<?php echo $customer_id;?>"/>
        <table class="form">
          <tr>
            <td><?php echo $_['entry_content']; ?></td>
            <td><textarea name="text" cols="40" rows="8" style="width: 99%"></textarea>
              <div style="margin-top: 10px; text-align: right;"><a id="button-service" class="button"><?php echo $_['button_add_service']; ?></a></div></td>
          </tr>
        </table>
      </div>
      <?php if ($maxmind_id) { ?>
      <div id="tab-fraud" class="vtabs-content">
        <table class="form">
          <?php if ($country_match) { ?>
          <tr>
            <td><?php echo $_['text_country_match']; ?></td>
            <td><?php echo $country_match; ?></td>
          </tr>
          <?php } ?>
          <?php if ($country_code) { ?>
          <tr>
            <td><?php echo $_['text_country_code']; ?></td>
            <td><?php echo $country_code; ?></td>
          </tr>
          <?php } ?>
          <?php if ($high_risk_country) { ?>
          <tr>
            <td><?php echo $_['text_high_risk_country']; ?></td>
            <td><?php echo $high_risk_country; ?></td>
          </tr>
          <?php } ?>
          <?php if ($distance) { ?>
          <tr>
            <td><?php echo $_['text_distance']; ?></td>
            <td><?php echo $distance; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_region) { ?>
          <tr>
            <td><?php echo $_['text_ip_region']; ?></td>
            <td><?php echo $ip_region; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_city) { ?>
          <tr>
            <td><?php echo $_['text_ip_city']; ?></td>
            <td><?php echo $ip_city; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_latitude) { ?>
          <tr>
            <td><?php echo $_['text_ip_latitude']; ?></td>
            <td><?php echo $ip_latitude; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_longitude) { ?>
          <tr>
            <td><?php echo $_['text_ip_longitude']; ?></td>
            <td><?php echo $ip_longitude; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_isp) { ?>
          <tr>
            <td><?php echo $_['text_ip_isp']; ?></td>
            <td><?php echo $ip_isp; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_org) { ?>
          <tr>
            <td><?php echo $_['text_ip_org']; ?></td>
            <td><?php echo $ip_org; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_asnum) { ?>
          <tr>
            <td><?php echo $_['text_ip_asnum']; ?></td>
            <td><?php echo $ip_asnum; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_user_type) { ?>
          <tr>
            <td><?php echo $_['text_ip_user_type']; ?></td>
            <td><?php echo $ip_user_type; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_country_confidence) { ?>
          <tr>
            <td><?php echo $_['text_ip_country_confidence']; ?></td>
            <td><?php echo $ip_country_confidence; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_region_confidence) { ?>
          <tr>
            <td><?php echo $_['text_ip_region_confidence']; ?></td>
            <td><?php echo $ip_region_confidence; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_city_confidence) { ?>
          <tr>
            <td><?php echo $_['text_ip_city_confidence']; ?></td>
            <td><?php echo $ip_city_confidence; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_postal_confidence) { ?>
          <tr>
            <td><?php echo $_['text_ip_postal_confidence']; ?></td>
            <td><?php echo $ip_postal_confidence; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_postal_code) { ?>
          <tr>
            <td><?php echo $_['text_ip_postal_code']; ?></td>
            <td><?php echo $ip_postal_code; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_accuracy_radius) { ?>
          <tr>
            <td><?php echo $_['text_ip_accuracy_radius']; ?></td>
            <td><?php echo $ip_accuracy_radius; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_net_speed_cell) { ?>
          <tr>
            <td><?php echo $_['text_ip_net_speed_cell']; ?></td>
            <td><?php echo $ip_net_speed_cell; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_metro_code) { ?>
          <tr>
            <td><?php echo $_['text_ip_metro_code']; ?></td>
            <td><?php echo $ip_metro_code; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_area_code) { ?>
          <tr>
            <td><?php echo $_['text_ip_area_code']; ?></td>
            <td><?php echo $ip_area_code; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_time_zone) { ?>
          <tr>
            <td><?php echo $_['text_ip_time_zone']; ?></td>
            <td><?php echo $ip_time_zone; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_region_name) { ?>
          <tr>
            <td><?php echo $_['text_ip_region_name']; ?></td>
            <td><?php echo $ip_region_name; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_domain) { ?>
          <tr>
            <td><?php echo $_['text_ip_domain']; ?></td>
            <td><?php echo $ip_domain; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_country_name) { ?>
          <tr>
            <td><?php echo $_['text_ip_country_name']; ?></td>
            <td><?php echo $ip_country_name; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_continent_code) { ?>
          <tr>
            <td><?php echo $_['text_ip_continent_code']; ?></td>
            <td><?php echo $ip_continent_code; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ip_corporate_proxy) { ?>
          <tr>
            <td><?php echo $_['text_ip_corporate_proxy']; ?></td>
            <td><?php echo $ip_corporate_proxy; ?></td>
          </tr>
          <?php } ?>
          <?php if ($anonymous_proxy) { ?>
          <tr>
            <td><?php echo $_['text_anonymous_proxy']; ?></td>
            <td><?php echo $anonymous_proxy; ?></td>
          </tr>
          <?php } ?>
          <?php if ($proxy_score) { ?>
          <tr>
            <td><?php echo $_['text_proxy_score']; ?></td>
            <td><?php echo $proxy_score; ?></td>
          </tr>
          <?php } ?>
          <?php if ($is_trans_proxy) { ?>
          <tr>
            <td><?php echo $_['text_is_trans_proxy']; ?></td>
            <td><?php echo $is_trans_proxy; ?></td>
          </tr>
          <?php } ?>
          <?php if ($free_mail) { ?>
          <tr>
            <td><?php echo $_['text_free_mail']; ?></td>
            <td><?php echo $free_mail; ?></td>
          </tr>
          <?php } ?>
          <?php if ($carder_email) { ?>
          <tr>
            <td><?php echo $_['text_carder_email']; ?></td>
            <td><?php echo $carder_email; ?></td>
          </tr>
          <?php } ?>
          <?php if ($high_risk_username) { ?>
          <tr>
            <td><?php echo $_['text_high_risk_username']; ?></td>
            <td><?php echo $high_risk_username; ?></td>
          </tr>
          <?php } ?>
          <?php if ($high_risk_password) { ?>
          <tr>
            <td><?php echo $_['text_high_risk_password']; ?></td>
            <td><?php echo $high_risk_password; ?></td>
          </tr>
          <?php } ?>
          <?php if ($bin_match) { ?>
          <tr>
            <td><?php echo $_['text_bin_match']; ?></td>
            <td><?php echo $bin_match; ?></td>
          </tr>
          <?php } ?>
          <?php if ($bin_country) { ?>
          <tr>
            <td><?php echo $_['text_bin_country']; ?></td>
            <td><?php echo $bin_country; ?></td>
          </tr>
          <?php } ?>
          <?php if ($bin_name_match) { ?>
          <tr>
            <td><?php echo $_['text_bin_name_match']; ?></td>
            <td><?php echo $bin_name_match; ?></td>
          </tr>
          <?php } ?>
          <?php if ($bin_name) { ?>
          <tr>
            <td><?php echo $_['text_bin_name']; ?></td>
            <td><?php echo $bin_name; ?></td>
          </tr>
          <?php } ?>
          <?php if ($bin_phone_match) { ?>
          <tr>
            <td><?php echo $_['text_bin_phone_match']; ?></td>
            <td><?php echo $bin_phone_match; ?></td>
          </tr>
          <?php } ?>
          <?php if ($bin_phone) { ?>
          <tr>
            <td><?php echo $_['text_bin_phone']; ?></td>
            <td><?php echo $bin_phone; ?></td>
          </tr>
          <?php } ?>
          <?php if ($customer_phone_in_billing_location) { ?>
          <tr>
            <td><?php echo $_['text_customer_phone_in_billing_location']; ?></td>
            <td><?php echo $customer_phone_in_billing_location; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ship_forward) { ?>
          <tr>
            <td><?php echo $_['text_ship_forward']; ?></td>
            <td><?php echo $ship_forward; ?></td>
          </tr>
          <?php } ?>
          <?php if ($city_postal_match) { ?>
          <tr>
            <td><?php echo $_['text_city_postal_match']; ?></td>
            <td><?php echo $city_postal_match; ?></td>
          </tr>
          <?php } ?>
          <?php if ($ship_city_postal_match) { ?>
          <tr>
            <td><?php echo $_['text_ship_city_postal_match']; ?></td>
            <td><?php echo $ship_city_postal_match; ?></td>
          </tr>
          <?php } ?>
          <?php if ($score) { ?>
          <tr>
            <td><?php echo $_['text_score']; ?></td>
            <td><?php echo $score; ?></td>
          </tr>
          <?php } ?>
          <?php if ($explanation) { ?>
          <tr>
            <td><?php echo $_['text_explanation']; ?></td>
            <td><?php echo $explanation; ?></td>
          </tr>
          <?php } ?>
          <?php if ($risk_score) { ?>
          <tr>
            <td><?php echo $_['text_risk_score']; ?></td>
            <td><?php echo $risk_score; ?></td>
          </tr>
          <?php } ?>
          <?php if ($queries_remaining) { ?>
          <tr>
            <td><?php echo $_['text_queries_remaining']; ?></td>
            <td><?php echo $queries_remaining; ?></td>
          </tr>
          <?php } ?>
          <?php if ($maxmind_id) { ?>
          <tr>
            <td><?php echo $_['text_maxmind_id']; ?></td>
            <td><?php echo $maxmind_id; ?></td>
          </tr>
          <?php } ?>
          <?php if ($error) { ?>
          <tr>
            <td><?php echo $_['text_error']; ?></td>
            <td><?php echo $error; ?></td>
          </tr>
          <?php } ?>
        </table>
      </div>
      <?php } ?>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
$('#invoice-generate').live('click', function() {
	$.ajax({
		url: '<?php echo UA('sale/order/createinvoiceno'); ?>&order_id=<?php echo $order_id; ?>',
		dataType: 'json',
		beforeSend: function() {
			$('#invoice').after('<img src="view/image/loading.gif" class="loading" style="padding-left: 5px;" />');	
		},
		complete: function() {
			$('.loading').remove();
		},
		success: function(json) {
			$('.success, .warning').remove();
						
			if (json['error']) {
				$('#tab-order').prepend('<div class="warning" style="display: none;">' + json['error'] + '</div>');
				
				$('.warning').fadeIn('slow');
			}
			
			if (json.invoice_no) {
				$('#invoice').fadeOut('slow', function() {
					$('#invoice').html(json['invoice_no']);
					
					$('#invoice').fadeIn('slow');
				});
			}
		}
	});
});

$('#shipping_carrier_code').live('change', function() {
	$.ajax({
		url: '<?php echo UA('sale/order/shippingcarrier'); ?>&order_id=<?php echo $order_id; ?>&code=' + $(this).val(),
		dataType: 'json',
		beforeSend: function() {
			$('#shipping_carrier_code').after('<img src="view/image/loading.gif" class="loading" style="padding-left: 5px;" />');	
		},
		complete: function() {
			$('.loading').remove();
		},
		success: function(json) {
			$('.success, .warning').remove();
						
			if (json['success']) {
				$('#shipping_carrier_msg').html('<img src="view/image/success.png" title="Success" style="padding-left: 5px;" />');
			}
			else {
				$('#shipping_carrier_msg').html('<img src="view/image/warning.png" title="Error" style="padding-left: 5px;" />');
			}			
		}
	});
});

$('#credit-add').live('click', function() {
	$.ajax({
		url: '<?php echo UA('sale/order/addcredit'); ?>&order_id=<?php echo $order_id; ?>',
		type: 'post',
		dataType: 'json',
		beforeSend: function() {
			$('#credit').after('<img src="view/image/loading.gif" class="loading" style="padding-left: 5px;" />');			
		},
		complete: function() {
			$('.loading').remove();
		},			
		success: function(json) {
			$('.success, .warning').remove();
			
			if (json['error']) {
				$('.box').before('<div class="warning" style="display: none;">' + json['error'] + '</div>');
				
				$('.warning').fadeIn('slow');
			}
			
			if (json['success']) {
                $('.box').before('<div class="success" style="display: none;">' + json['success'] + '</div>');
				
				$('.success').fadeIn('slow');
				
				$('#credit').html('<b>[</b> <a id="credit-remove"><?php echo $_['text_credit_remove']; ?></a> <b>]</b>');
			}
		}
	});
});

$('#credit-remove').live('click', function() {
	$.ajax({
		url: '<?php echo UA('sale/order/removecredit'); ?>&order_id=<?php echo $order_id; ?>',
		type: 'post',
		dataType: 'json',
		beforeSend: function() {
			$('#credit').after('<img src="view/image/loading.gif" class="loading" style="padding-left: 5px;" />');			
		},
		complete: function() {
			$('.loading').remove();
		},			
		success: function(json) {
			$('.success, .warning').remove();
						
			if (json['error']) {
				$('.box').before('<div class="warning" style="display: none;">' + json['error'] + '</div>');
				
				$('.warning').fadeIn('slow');
			}
			
			if (json['success']) {
                $('.box').before('<div class="success" style="display: none;">' + json['success'] + '</div>');
				
				$('.success').fadeIn('slow');
				
				$('#credit').html('<b>[</b> <a id="credit-add"><?php echo $_['text_credit_add']; ?></a> <b>]</b>');
			}
		}
	});
});

$('#reward-add').live('click', function() {
	$.ajax({
		url: '<?php echo UA('sale/order/addreward'); ?>&order_id=<?php echo $order_id; ?>',
		type: 'post',
		dataType: 'json',
		beforeSend: function() {
			$('#reward').after('<img src="view/image/loading.gif" class="loading" style="padding-left: 5px;" />');			
		},
		complete: function() {
			$('.loading').remove();
		},									
		success: function(json) {
			$('.success, .warning').remove();
						
			if (json['error']) {
				$('.box').before('<div class="warning" style="display: none;">' + json['error'] + '</div>');
				
				$('.warning').fadeIn('slow');
			}
			
			if (json['success']) {
                $('.box').before('<div class="success" style="display: none;">' + json['success'] + '</div>');
				
				$('.success').fadeIn('slow');

				$('#reward').html('<b>[</b> <a id="reward-remove"><?php echo $_['text_reward_remove']; ?></a> <b>]</b>');
			}
		}
	});
});

$('#reward-remove').live('click', function() {
	$.ajax({
		url: '<?php echo UA('sale/order/removereward'); ?>&order_id=<?php echo $order_id; ?>',
		type: 'post',
		dataType: 'json',
		beforeSend: function() {
			$('#reward').after('<img src="view/image/loading.gif" class="loading" style="padding-left: 5px;" />');
		},
		complete: function() {
			$('.loading').remove();
		},				
		success: function(json) {
			$('.success, .warning').remove();
						
			if (json['error']) {
				$('.box').before('<div class="warning" style="display: none;">' + json['error'] + '</div>');
				
				$('.warning').fadeIn('slow');
			}
			
			if (json['success']) {
                $('.box').before('<div class="success" style="display: none;">' + json['success'] + '</div>');
				
				$('.success').fadeIn('slow');
				
				$('#reward').html('<b>[</b> <a id="reward-add"><?php echo $_['text_reward_add']; ?></a> <b>]</b>');
			}
		}
	});
});

$('#commission-add').live('click', function() {
	$.ajax({
		url: '<?php echo UA('sale/order/addcommission'); ?>&order_id=<?php echo $order_id; ?>',
		type: 'post',
		dataType: 'json',
		beforeSend: function() {
			$('#commission').after('<img src="view/image/loading.gif" class="loading" style="padding-left: 5px;" />');			
		},
		complete: function() {
			$('.loading').remove();
		},			
		success: function(json) {
			$('.success, .warning').remove();
						
			if (json['error']) {
				$('.box').before('<div class="warning" style="display: none;">' + json['error'] + '</div>');
				
				$('.warning').fadeIn('slow');
			}
			
			if (json['success']) {
                $('.box').before('<div class="success" style="display: none;">' + json['success'] + '</div>');
				
				$('.success').fadeIn('slow');
                
				$('#commission').html('<b>[</b> <a id="commission-remove"><?php echo $_['text_commission_remove']; ?></a> <b>]</b>');
			}
		}
	});
});

$('#commission-remove').live('click', function() {
	$.ajax({
		url: '<?php echo UA('sale/order/removecommission'); ?>&order_id=<?php echo $order_id; ?>',
		type: 'post',
		dataType: 'json',
		beforeSend: function() {
			$('#commission').after('<img src="view/image/loading.gif" class="loading" style="padding-left: 5px;" />');			
		},
		complete: function() {
			$('.loading').remove();
		},			
		success: function(json) {
			$('.success, .warning').remove();
						
			if (json['error']) {
				$('.box').before('<div class="warning" style="display: none;">' + json['error'] + '</div>');
				
				$('.warning').fadeIn('slow');
			}
			
			if (json['success']) {
                $('.box').before('<div class="success" style="display: none;">' + json['success'] + '</div>');
				
				$('.success').fadeIn('slow');
				
				$('#commission').html('<b>[</b> <a id="commission-add"><?php echo $_['text_commission_add']; ?></a> <b>]</b>');
			}
		}
	});
});

$('#history .pagination a').live('click', function() {
	$('#history').load(this.href);
	
	return false;
});			

$('#service .pagination a').live('click', function() {
	$('#service').load(this.href);
	
	return false;
});

$('#history').load('<?php echo UA('sale/order/history'); ?>&order_id=<?php echo $order_id; ?>');
$('#shipping-history').load('<?php echo UA('sale/order/shipping_history'); ?>&order_id=<?php echo $order_id; ?>');
$('#service').load('<?php echo UA('sale/order/service'); ?>&order_id=<?php echo $order_id; ?>');

$('#button-history').live('click', function() {
	$.ajax({
		url: '<?php echo UA('sale/order/history'); ?>&order_id=<?php echo $order_id; ?>',
		type: 'post',
		dataType: 'html',
		data: 'order_status_id=' + encodeURIComponent($('select[name=\'order_status_id\']').val()) + '&notify=' + encodeURIComponent($('input[name=\'notify\']').attr('checked') ? 1 : 0) + '&append=' + encodeURIComponent($('input[name=\'append\']').attr('checked') ? 1 : 0) + '&comment=' + encodeURIComponent($('textarea[name=\'comment\']').val()),
		beforeSend: function() {
			$('.success, .warning').remove();
			$('#button-history').attr('disabled', true);
			$('#history').prepend('<div class="attention"><img src="view/image/loading.gif" alt="" /> <?php echo $_['text_wait']; ?></div>');
		},
		complete: function() {
			$('#button-history').attr('disabled', false);
			$('.attention').remove();
		},
		success: function(html) {
			$('#history').html(html);
			
			$('textarea[name=\'comment\']').val('');
			
			$('#order-status').html($('select[name=\'order_status_id\'] option:selected').text());
		}
	});
});

$('#button-service').live('click', function() {
	$.ajax({
		url: '<?php echo UA('sale/order/service'); ?>&order_id=<?php echo $order_id; ?>',
		type: 'post',
		dataType: 'html',
		data: 'customer_id=' + $('input[name="customer_id"]').val() + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()),
		beforeSend: function() {
			$('.success, .warning').remove();
			$('#button-service').attr('disabled', true);
			$('#service').prepend('<div class="attention"><img src="view/image/loading.gif" alt="" /> <?php echo $_['text_wait']; ?></div>');
		},
		complete: function() {
			$('#button-service').attr('disabled', false);
			$('.attention').remove();
		},
		success: function(html) {
			$('#service').html(html);
			
			$('textarea[name=\'text\']').val('');
		}
	});
});

$('#button-shipping-history').live('click', function() {
	if ($('input[name="ship_date"]').val() == '') {
		$.jBox.tip('<?php echo $_['error_shipping_date'];?>', 'error');
		$('input[name="ship_date"]').focus();
		return;
	}
	if ($('select[name="ship_carrier"]').val() == '') {
		$.jBox.tip('<?php echo $_['error_shipping_carrier'];?>', 'error');
		$('input[name="ship_carrier"]').focus();
		return;
	}
	$.ajax({
		url: '<?php echo UA('sale/order/shipping_history'); ?>&order_id=<?php echo $order_id; ?>',
		type: 'post',
		dataType: 'html',
		data: $('#shipping-history-form input[type=\'text\'], #shipping-history-form select, #shipping-history-form textarea'),
		beforeSend: function() {
			$('.success, .warning').remove();
			$('#button-shipping-history').attr('disabled', true);
			$('#shipping-history').prepend('<div class="attention"><img src="view/image/loading.gif" alt="" /> <?php echo $_['text_wait']; ?></div>');
		},
		complete: function() {
			$('#button-shipping-history').attr('disabled', false);
			$('.attention').remove();
		},
		success: function(html) {
			$('#shipping-history').html(html);
			$('input[name=\'track_number\']').val('');
			$('textarea[name=\'remark\']').val('');
		}
	});
});
//--></script> 
<script type="text/javascript"><!--
$('.vtabs a').tabs();
//--></script> 
<script type="text/javascript"><!--
$(document).ready(function() {
	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
});
//--></script> 
<?php echo $footer; ?>